package com.rongc.client.freight.utils;


import com.rongc.client.core.utils.StringUtils;
import com.rongc.client.freight.UniApplication;
import com.rongc.client.freight.base.model.BaseDic;
import com.rongc.client.freight.base.model.UserBean;
import com.rongc.client.freight.base.request.result.UserResult;

/**
 * Created by Bruce on 2017/6/24.
 */
public class UserUtils {
    public static void makeUser(UserResult result){
        UserBean user = UniApplication.getInstance().getUserInfo();
        user.setUserId(result.getId());
        user.setType(result.getType());
        user.setHead(result.getImg());
        user.setNickname(result.getNick());
        user.setBalance(result.getBalance());
        user.setPayPwd(result.getPay_pwd());
        user.setPassword(result.getPassword());
        user.setPhone(result.getMobile());
        user.setCreateTime(result.getCreate_time());

        user.setBanktype(result.getBank_type());
        user.setBankcard(result.getBank_card());
        user.setBankphone(result.getBank_mobile());
        user.setIdcard(result.getId_card());
        user.setRealname(result.getName());

        user.setMarkCount(result.getQiandao_number());
        user.setMarkTime(result.getQiandao_time());
        if(StringUtils.isNotEmpty(result.getXiadanNumber()))
            user.setCountXD(result.getXiadanNumber());
        if(StringUtils.isNotEmpty(result.getJiedanNumber()))
            user.setCountJD(result.getJiedanNumber());
        if(StringUtils.isNotEmpty(result.getWy_number()))
            user.setCountWY(result.getWy_number());
        user.setIntegral(result.getScore());

        user.save();
    }

    public static void mockUser(){
        UserBean user = UniApplication.getInstance().getUserInfo();
        user.setHead("https://ss1.baidu.com/70cFfyinKgQFm2e88IuM_a/forum/pic/item/6159252dd42a2834dace5fc352b5c9ea14cebf8a.jpg");
        user.setUserId("1");
        user.setNickname("Dasm");
        user.setPhone("13554342081");
        user.setType(BaseDic.IdentityType.OWNER_TYPE);
        user.setBalance("200");
        user.setCountJD("10");
        user.setCountXD("12");
        user.setCountWY("1");
        user.setIntegral("2000");
        user.save();
    }

}
